package es.udc.emarketapp.emarket.test;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

import es.udc.emarketapp.emarket.model.country.vo.CountryVO;
import es.udc.emarketapp.emarket.model.country.dao.SQLCountryDAO;
import es.udc.emarketapp.emarket.model.country.dao.SQLCountryDAO;
import es.udc.emarketapp.emarket.model.country.dao.SQLCountryDAOFactory;

import es.udc.fbellas.j2ee.util.sql.SimpleDataSource;



public final class PruebaCountry {
	
    public static void main (String[] args) throws Exception {
    	

     	
    	Connection connection = null;
    	Statement statement = null;
    		
    	try {	
        
    		SimpleDataSource dataSource = new SimpleDataSource();    
    	
    		connection = dataSource.getConnection();

    		    		
           //Creamos un SQLCountryDAO
    		SQLCountryDAO countryDAO = SQLCountryDAOFactory.getDAO(); 
    			
    		  		
    		
    		    	
    	  	//Prueba findById ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    	  	/*
    		
    		CountryVO countryVO = countryDAO.findById(connection, "AR");
    		System.out.println(countryVO.toString());
    		
    		*/
    		
    		//Prueba findAllCoountries ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    		
    		List<CountryVO> countryVOs = countryDAO.findAllCountries(connection,1,200);
    		System.out.println(countryVOs.toString());
    		
    		 
    		
    		 
        } finally {
            try {
                 if (connection != null) {
                     connection.close();
                 }
            } catch (SQLException e) {
                 e.printStackTrace();
            }
        } // try
    } // main
} // class